package com.thalesgroup.preferenceFramework.models.LCPnet.impl;

import junit.framework.TestCase;

import org.eclipse.emf.common.util.EList;
import org.junit.Before;
import org.junit.Test;

import com.thalesgroup.preferenceFramework.models.Arc;
import com.thalesgroup.preferenceFramework.models.Outcome;
import com.thalesgroup.preferenceFramework.models.LCPnet.CIArc;
import com.thalesgroup.preferenceFramework.models.LCPnet.COutcome;
import com.thalesgroup.preferenceFramework.models.LCPnet.LCPnet;
import com.thalesgroup.preferenceFramework.models.LCPnet.LNode;
import com.thalesgroup.preferenceFramework.models.LCPnet.exceptions.LCPnetEvaluationException;

public class CIArcImplTests extends TestCase {
	private LCPnet net;
	
	@Before
	public void setUp() throws Exception {
		net = LCPnetImpl.load("tests/com/thalesgroup/preferenceFramework/models/LCPnet/impl/ciarc_test.lcpnet");
	}

	@Test
	public void testGetArcDirectionCOutcome() throws LCPnetEvaluationException {
		EList<Arc> arcs = net.getArcs();
		for (Arc arc : arcs) {
			if(arc instanceof CIArc) {
				CIArc ciarc = (CIArc) arc;

				EList<Outcome> outcomes = net.getOutcomes();
				for (Outcome outcome : outcomes) {
					if(outcome instanceof COutcome) {
						//Display computed CI-Arc
						EList<LNode> arcDirection = ciarc.getArcDirection((COutcome) outcome);
						assertEquals(arcDirection.get(0).getName(), "B");
						assertEquals(arcDirection.get(1).getName(), "S");
						
						return;
					}
				}
			}
		}
		
		fail("CI-Arc our Outcome not found in test file");
	}

}
